Skip to content

feat: SQL query filter follow-ups: table autocomplete, type rename, type-switch fix, E2E tests - #3719

Merged
kodiakhq[bot] merged 5 commits into
mainfrom
claude/sql-filter-autocomplete
Nov 19, 2026
Merged

kodiakhq[bot] merged 5 commits into
mainfrom
claude/sql-filter-autocomplete

Conversation

@karl-power

@karl-power karl-power commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-ups from review on #3678: autocomplete table and column names in the SQL query filter editor, rename "Queried values", fix a validation bug when switching filter types, and add E2E coverage for SQL query filters. One commit per change:

  • feat: autocomplete table and column names in the SQL query filter editor. The editor now suggests the tables and columns of the selected connection's sources, like the Raw SQL tile. A connection variable suggests the tables of the connection it currently selects. The tile's table-list logic moves to a shared getTableConnectionsForConnection() in utils.ts, which both editors use.
  • feat: rename the Queried values filter type to SQL expression values. This tells it apart from "SQL query values" and "PromQL label values". The two SQL types are now next to each other in the type dropdown.
  • fix: clear the previous filter type's rules when switching types. react-hook-form keeps a field's validation rules after its input unmounts, and merges the next input's rules over them. Switching from "PromQL label values" to "SQL query values" failed with "Select a PromQL source", and a new SQL query filter couldn't be saved without a source because "SQL expression values" (the default type) requires one. Changing the type now clears the old rules before the next editor registers its own.
  • test: add E2E tests for SQL query dashboard filters. Five tests: values listed in query order and selected by variable name, values narrowed by another filter's variable using $__sourceTable and $__filter, a connection variable, a data source variable, and a query error shown in the preview and on the dropdown.

Screenshots or video

Not captured. The visible changes are autocomplete suggestions in the SQL query filter editor and the renamed, reordered type dropdown.

How to reproduce

Starting point: yarn dev, any dashboard, with a Logs source on the local connection.

On main:

  1. Click Edit filters and variables, then Add new filter, and choose PromQL label values.
  2. Switch the type to SQL query values, fill in a name, connection and query, and click Save filter. It fails with "Select a PromQL source".
  3. In the SQL editor, start typing a table name. Only keywords, functions and macros are suggested.

On this branch:

  1. Repeat step 2. The filter saves.
  2. In the SQL editor, type otel. The tables of the connection's sources are suggested, and after FROM, their columns.
  3. Open the Type dropdown. It lists SQL expression values then SQL query values, and "Queried values" is gone.

How to test on Vercel preview

Preview routes: /dashboards

Steps:

  1. Create a new dashboard and click Edit filters and variables, then Add new filter.
  2. Open the Type dropdown and verify the first two options are "SQL expression values" and "SQL query values".
  3. Choose SQL query values, pick the demo connection, and type SELECT * FROM otel in the SQL editor. Verify table names appear in the suggestions.

References

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 19, 2026 2:34pm UTC
hyperdx-storybook Ready Ready Preview Nov 19, 2026 2:34pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 04ac458

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@karl-power
karl-power force-pushed the claude/sql-filter-autocomplete branch from faebc7c to 08849ac Compare November 19, 2026 09:13
@karl-power
karl-power changed the base branch from sql-dashboard-variables-source to main November 19, 2026 09:13
@karl-power karl-power closed this Nov 19, 2026
@karl-power karl-power reopened this Nov 19, 2026
@karl-power
karl-power marked this pull request as ready for review November 19, 2026 09:14
@karl-power
karl-power requested a review from a team as a code owner November 19, 2026 09:14
@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 4
  • Production lines changed: 126 (+ 692 in test files, excluded from tier calculation)
  • Branch: claude/sql-filter-autocomplete
  • Author: karl-power

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 107 in total (1.13%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

3 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 3 P3

No inline comments. 3 P3 folded at the bottom.

🔵 3 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/DashboardFiltersModal/DashboardFilterEditForm.tsx:132 — The key in values type guard is always true, so it works as a hidden as cast → Every key that Object.keys(values) returns is already in values, so this filter can never drop anything. It only narrows string to keyof FilterFormValues, which goes around the 'Avoid as casts' rule. Either iterate a typed key list (for example a satisfies (keyof FilterFormValues)[] constant next to toFormValues in filterFormState.ts), or remove the filter and state the narrowing in one place.
  • 🔵 P3 packages/app/tests/e2e/page-objects/DashboardPage.ts:1097 — The new CodeMirror select-all, Backspace and insertText sequence copies code already in this file → fillSqlQueryFilterForm repeats the editor-clearing steps from the WHERE-clause filler at DashboardPage.ts:1093-1102 line for line, including the darwin Meta/Control branch and the insertText comment. replaceEditorText in tests/e2e/utils/locators.ts does nearly the same thing. Move this into one shared helper, for example a replaceEditorText variant that uses insertText (or an option on it), and call it from both places.
  • 🔵 P3 packages/app/src/components/DashboardFiltersModal/__tests__/DashboardFiltersModal.promql.test.tsx:362 — The SqlQueryFilterEditForm mock is copied word for word from DashboardFiltersModal.test.tsx → This stub is identical to the one added at DashboardFiltersModal.test.tsx:435-449. If the real form's registered fields change, the two copies have to be updated together, and one will fall out of date. Move the stub into a shared __tests__ helper or a __mocks__ module and import it in both files.

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 479 passed • 1 skipped • 1063s

Status Count
✅ Passed 479
❌ Failed 0
⚠️ Flaky 3
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The three substantive changes are sound. The changeType() rule-clearing fix is correct and well-tested: every schema-required field is re-registered unconditionally when its editor mounts, so clearing rules on type-switch cannot leave a required field unguarded; the only conditionally-registered field (sourceMetricType) is optional in the schema. The getTableConnectionsForConnection() extraction preserves the prior inline logic, and the controlled→manual Select keeps react-hook-form as the single source of truth. No shipping blocker.

🟡 P2 -- recommended

  • packages/app/src/__tests__/utils.test.ts:54 -- getTableConnectionsForConnection() has metric-source (!isMetricSource base-table exclusion) and trace-source (isTraceSource materialized-views) branches that no test exercises; the fixtures are all TLogSource.
    • Fix: Add a TMetricSource fixture asserting metric tables are returned without the base table, a trace source with materializedViews, and a mixed-source-kinds-on-one-connection case.
    • testing, correctness, kieran-typescript, adversarial
🔵 P3 nitpicks (2)
  • packages/app/src/components/DashboardFiltersModal/DashboardFilterEditForm.tsx:139 -- Object.keys(values).filter((key): key is keyof FilterFormValues => key in values) is a no-op predicate (every key is by definition in values); it disguises a type cast as a runtime guard and can mislead a future maintainer.

    • Fix: Replace with an explicit cast, e.g. const fields = Object.keys(values) as (keyof FilterFormValues)[].
    • maintainability, kieran-typescript
  • packages/app/src/utils.ts:1419 -- When two enabled sibling sources on a connection resolve to the same db.table, or a source has an empty/missing from, the helper emits duplicate or blank autocomplete entries; this inline behavior was previously only in the tile editor and is now newly exposed in the SQL query filter editor.

    • Fix: Deduplicate entries by connectionId:databaseName.tableName and skip sources that produce a blank table name.

Reviewers (7): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, adversarial.

Testing gaps:

  • The changeType unit tests mock each editor as a raw control.register(...) input, but the real editors register the shared source field through Controller/useController; the RHF rule-merge-on-re-register mechanism the fix actually depends on is not reproduced by the mocks, so the tests could stay green while production regresses (or vice versa).
  • No test confirms that switching away from a type clears required rules on non-source shared fields (e.g. connection, sqlTemplate); coverage only exercises the source field.
  • No assertion that the FILTER_TYPE_OPTIONS rename/reorder leaves the persisted type enum values unchanged, so a regression affecting existing dashboards or deep links would not be caught.
  • Prior PR comments were bot-only (Vercel, changeset-bot); no human review feedback to verify.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@karl-power
karl-power requested a review from pulpdrew November 19, 2026 10:14

@pulpdrew pulpdrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kodiakhq
kodiakhq Bot merged commit 0c77d52 into main Nov 19, 2026
27 of 28 checks passed
@kodiakhq
kodiakhq Bot deleted the claude/sql-filter-autocomplete branch November 19, 2026 14:38

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 04ac4587 Deployed Nov 19, 2026 by vercel[bot]
Preview – hyperdx-storybook — 04ac4587 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants